package com.muyu.danmo.controller;

import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoArtContent;
import com.muyu.danmo.service.IDanmoArtContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 专业简介Controller
 * 
 * @author yangle
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/danmoArtContent")
public class DanmoArtContentController extends BaseController
{
    @Autowired
    private IDanmoArtContentService danmoArtContentService;

    /**
     * 查询专业简介列表
     */
//    @RequiresPermissions("system:danmoArtContent:list")
    @PostMapping("/list")
    public Result<List<DanmoArtContent>> list(@RequestBody DanmoArtContent danmoArtContent)
    {

        List<DanmoArtContent> list = danmoArtContentService.selectDanmoArtContentList(danmoArtContent);
        return Result.success(list);
    }

    /**
     * 导出专业简介列表
     */
//    @RequiresPermissions("system:danmoArtContent:export")
    @Log(title = "专业简介", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoArtContent danmoArtContent)
    {
        List<DanmoArtContent> list = danmoArtContentService.selectDanmoArtContentList(danmoArtContent);
        ExcelUtil<DanmoArtContent> util = new ExcelUtil<DanmoArtContent>(DanmoArtContent.class);
        util.exportExcel(response, list, "专业简介数据");
    }

    /**
     * 获取专业简介详细信息
     */
//    @RequiresPermissions("system:danmoArtContent:query")
    @GetMapping(value = "/{contentId}")
    public Result getInfo(@PathVariable("contentId") Long contentId)
    {
        return success(danmoArtContentService.selectDanmoArtContentByContentId(contentId));
    }

    /**
     * 新增专业简介
     */
//    @RequiresPermissions("system:danmoArtContent:add")
    @Log(title = "专业简介", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoArtContent danmoArtContent)
    {
        return toAjax(danmoArtContentService.insertDanmoArtContent(danmoArtContent));
    }

    /**
     * 修改专业简介
     */
//    @RequiresPermissions("system:danmoArtContent:edit")
    @Log(title = "专业简介", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoArtContent danmoArtContent)
    {
        return toAjax(danmoArtContentService.updateDanmoArtContent(danmoArtContent));
    }

    /**
     * 删除专业简介
     */
//    @RequiresPermissions("system:danmoArtContent:remove")
    @Log(title = "专业简介", businessType = BusinessType.DELETE)
	@DeleteMapping("/{contentIds}")
    public Result remove(@PathVariable Long[] contentIds)
    {
        return toAjax(danmoArtContentService.deleteDanmoArtContentByContentIds(contentIds));
    }


}
